package edu.cs.usask.ca.silver.api.persistence;

import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.UUID;

import javax.sql.DataSource;

import org.w3c.dom.Document;

/**
 * 
 * This interface defines all necessary functions a storage implementation for
 * Silver requires. DbStorage is the only implementation of the storage
 * interface at the time, but it is conceivable that multiple different
 * implementations could be used (possibly, even in connection with each other -
 * local + remote).
 * 
 * @author Daniel Funk
 * @author Yudi Xue
 */

public interface StorageI {

	/* ==== Methods to Satisfy requests from SilverService ==== */

	/**
	 * Creates whatever empty tables, files, folders, etc. that are needed for
	 * the chosen storage type.
	 * 
	 * @return true if success, false if initialization fails
	 */
	public boolean initializeStorage() throws Exception;

	/**
	 * ping database connection, can be called frequently.
	 * 
	 * @return true if connection is successful, false if connection is failed
	 * @throws SQLException
	 *             if the connection failed.
	 */
	public boolean pingConnection() throws SQLException;

	/**
	 * removes all files, tables, folders, etc. that were created for the chosen
	 * storage type.
	 * 
	 * @return true if success, false if removal fails
	 */
	public boolean clearStorage() throws Exception;

	/**
	 * Backup to a read-only database zip file to the file path
	 * 
	 * @param destination
	 *            - the path where the back up file will be stored.
	 * @return true if success, false if backup fails
	 */
	// public boolean backupStorage(String destination);

	/**
	 * Returns an array of unique integers - the IDs of all model projects in
	 * storage
	 * 
	 * @return
	 */
	public ArrayList<UUID> getAllUserIDs() throws Exception;

	/* ==== Methods to Satisfy requests from User ==== */
	/**
	 * Add user to silver database
	 * 
	 * @param uFirstName
	 *            The first name of the user
	 * @param uLastName
	 *            The last name of the user
	 * @param uEmail
	 *            The user's email
	 * @param uPasswod
	 *            The user's password
	 * @return a unique integer id of the user
	 */
	public UUID addUser(String uFirstName, String uLastName, String uEmail,
			String uPasswd) throws Exception;

	/**
	 * Add a user to silver database and associate the user with a private group
	 * 
	 * @param uFirstName
	 *            The first name of the user
	 * @param uLastName
	 *            The last name of the user
	 * @param uEmail
	 *            The email of the user
	 * @param uPasswd
	 *            The password of the user
	 * @param uDescr
	 *            A textual description of the project
	 * @return A unique integer ID (unique across all of Silver)
	 * @throws Exception
	 */
	public UUID addUserAndPrivateGroup(String uFirstName, String uLastName,
			String uEmail, String uPasswd, int privateGroupId) throws Exception;

	/**
	 * Get the entire contents (non-recursive) of a user as XML string.
	 * 
	 * @param uId
	 *            The unique integer ID of the user
	 * @return A string containing the XML representation for the user
	 */
	public String getUserAsXML(UUID uId) throws Exception;

	/**
	 * Get the basic info (first name, last name, email and pass) of a user
	 * 
	 * @param uId
	 *            the unique id of the user
	 * @return String array containing the basic info
	 * 
	 */
	public String[] getUserBasicInfoIntoStringArray(UUID uId) throws Exception;

	/**
	 * Get the first name of a user
	 * 
	 * @param uId
	 *            The unique integer ID of the user
	 * @return A string containing the user first name
	 */
	public String getUserFirstName(UUID uId) throws Exception;

	/**
	 * Get the last name of a user
	 * 
	 * @param uId
	 *            The unique integer ID of the user
	 * @return A string containing the user last name
	 */
	public String getUserLastName(UUID uId) throws Exception;

	/**
	 * Get the email of a user
	 * 
	 * @param uId
	 *            The unique integer ID of the user
	 * 
	 * @return A string containing the user email
	 */
	public String getUserEmail(UUID uId) throws Exception;

	/**
	 * get the private group that belongs to a user
	 * 
	 * @param uId
	 *            the unique integer ID of the user
	 * @return A unique group ID which represents the user's private group
	 * @throws Exception
	 */
	public UUID getUserPrivateGroupId(UUID uId) throws Exception;

	/**
	 * Verify the User Password
	 * 
	 * @param pass
	 *            The password defined by user
	 * @return true if password is correct, false if password is incorrect
	 * @throws Exception
	 */
	public boolean verifyUserPassword(String email, String pass)
			throws Exception;

	/**
	 * Get the time of the user's last update.
	 * 
	 * @param uId
	 *            user database id
	 * @return the time of the user's last update.
	 */
	public Date getUserLastUpdatedTime(UUID uId) throws Exception;

	/**
	 * Get the creation date of a user
	 * 
	 * @param uId
	 *            user database id
	 * @return The user registration date
	 */
	public Date getUserRegistrationDate(UUID uId) throws Exception;

	/**
	 * Get the time of creation of a user
	 * 
	 * @param uId
	 * @return The user registration time
	 */
	public Date getUserRegistrationTime(UUID uId) throws Exception;

	/**
	 * Get the list of group IDs of all groups user has participated in.
	 * 
	 * @param uId
	 *            The unique integer ID of the user
	 * @return An ArrayList<Integers> containing all group ids
	 */
	public ArrayList<UUID> getUserParticipatedGroupIds(UUID uId)
			throws Exception;

	/**
	 * Used for User login. After Checking email and password, a unique user id
	 * is returned from the database.
	 * 
	 * The user id is then to be used for extracting information for the user.
	 * 
	 * @param uEmail
	 *            TODO
	 * @param uPasswd
	 *            TODO
	 * 
	 * @return UUID the unique user id from database
	 */
	public UUID getUserIdentityBasedOnEmailAndPassword(String uEmail,
			String uPasswd) throws Exception;

	/**
	 * Update user's first name
	 * 
	 * @param uId
	 *            the unique user id
	 * @param updatedFirstName
	 *            the new first name
	 * @return whether the action has succeeded
	 */
	public boolean setUserFirstName(UUID uId, String updatedFirstName)
			throws Exception;

	/**
	 * Update user's last name
	 * 
	 * @param uId
	 *            the unique user id
	 * @param updatedLastName
	 *            the new last name
	 * @return whether the action has succeeded
	 */
	public boolean setUserLastName(UUID uId, String updatedLastName)
			throws Exception;

	/**
	 * Update user's email address
	 * 
	 * @param uId
	 *            the unique user id
	 * @param updatedEmail
	 *            the new email address
	 * @return whether the action succeeded
	 */
	public boolean setUserEmail(UUID uId, String updatedEmail) throws Exception;

	/**
	 * Update user's passwd. The method is only limited to the user's own
	 * password.
	 * 
	 * @param uId
	 * @param updatedPasswd
	 * @return
	 * @throws Exception
	 */
	public boolean setUserPasswd(UUID uId, String updatedPasswd)
			throws Exception;

	/**
	 * Update user's private group id.
	 * 
	 * @param uId
	 *            user id
	 * @param groupId
	 *            the user's group id
	 * @return whether the action succeeded
	 */
	public boolean setUserPrivateGroupId(UUID uId, UUID groupId)
			throws Exception;

	public boolean deleteUser(UUID uId) throws Exception;

	/* ==== Methods to Satisfy requests from Group ==== */

	/**
	 * 
	 */
	public UUID addGroup(String gName, UUID gOwnerId, String gPrivacy,
			String gDescription) throws Exception;

	public ArrayList<UUID> getAllGroupIDs() throws Exception;

	/**
	 * Get all group names and return them in an array list
	 * 
	 * @return ArrayList<String> an array of group names.
	 * @throws SQLException
	 */
	public ArrayList<String> getAllGroupNames() throws Exception;

	/**
	 * Get all group identities and group names in a bimap
	 * 
	 * @param gId
	 * @return com.google.collect.BiMap <UUID, String>
	 * @throws Exception
	 *             SQLException
	 */
	public HashMap<UUID, String> getAllGroupIDNameAsHashedMap()
			throws Exception;

	public String getGroupName(UUID gId) throws Exception;

	public UUID getGroupOwnerID(UUID gId) throws Exception;

	public String getGroupOwnerName(UUID gId) throws Exception;

	public String getGroupPrivacy(UUID gId) throws Exception;

	public String getGroupDescription(UUID gId) throws Exception;

	public Date getGroupUpdateTime(UUID gId) throws Exception;

	public Date getGroupCreationDate(UUID gId) throws Exception;

	public ArrayList<UUID> getGroupContainingModelProjectIDs(UUID gId)
			throws Exception;

	public ArrayList<UUID> getGroupContainingUserIDs(UUID gId) throws Exception;

	public boolean setGroupName(UUID gId, String updatedName) throws Exception;

	public boolean setGroupPrivacy(UUID gId, String updatedPrivacy)
			throws Exception;

	public boolean setGroupOwnerID(UUID gId, UUID updatedOwnerId)
			throws Exception;

	public boolean setGroupDescription(UUID gId, String updatedGroupDescription)
			throws Exception;

	public boolean deleteGroup(UUID gId) throws Exception;

	public boolean removeUserFromGroup(UUID uId, UUID gId) throws Exception;

	/**
	 * Add a user to the user group.
	 * 
	 * When a group is created, the owner should be added to the group table.
	 * 
	 * 
	 * @param uId
	 * @param gId
	 * @return
	 * @throws Exception
	 */
	public boolean addUserToGroup(UUID uId, UUID gId) throws Exception;

	/**
	 * get all Users within this group, including the owner
	 * 
	 * @param uId
	 * @return Returns an array of unique integers - the IDs of all user ids in
	 *         group
	 */
	public ArrayList<UUID> getAllUsersWithinThisGroup(UUID uId)
			throws Exception;

	/* ==== Methods to Satisfy requests from ModelProject ==== */

	/**
	 * get all ModelProject ids
	 * 
	 * @return Returns an array of unique integers - the IDs of all model
	 *         projects in storage
	 */

	public ArrayList<UUID> getAllModelProjectIDs() throws Exception;

	/**
	 * Add a new model project to the storage layer.
	 * 
	 * @param groupId
	 *            the unique group id.
	 * @param mpName
	 *            The name of the Project
	 * @param mpCreator
	 *            The creator
	 * @param mpType
	 *            The supported type of Silver defined by StorageType
	 * @param mpDescr
	 *            A textual description of the project
	 * 
	 * @return A unique integer ID (unique across all of Silver)
	 * @throws Exception
	 */
	public UUID addModelProject(UUID groupId, String mpName, String mpCreator,
			String mpType, String mpDescr) throws Exception;

	public String[] getModelProjectNamesByGroupId(UUID gId) throws Exception;

	/**
	 * Get the entire contents (non-recursive) of a model project as XML string.
	 * 
	 * @param mpId
	 *            The unique integer ID of the project
	 * @return A string containing the XML representation
	 */
	public String getModelProjectAsXML(UUID mpId) throws Exception;

	/**
	 * Get the latest version representation of current model project
	 * 
	 * @param mpId
	 *            the model project database id
	 * @return the unique string representation of the mp version
	 */
	public UUID getMpVersion(UUID mpId) throws Exception;

	/**
	 * Get the owning group id of the current model project
	 * 
	 * @param mpId
	 *            the unique model project Id
	 * @return UUID id of the group
	 * 
	 */
	public UUID getMpParentGroup(UUID mpId) throws Exception;

	/**
	 * Get the last updated time of the model project
	 * 
	 * @param mpId
	 *            the model project database id
	 * @return the time the model project lastly updated
	 */
	public Date getMpLastUpdateTime(UUID mpId) throws Exception;

	/**
	 * Get the name of a project
	 * 
	 * @param mpId
	 *            The unique integer ID of the project
	 * @return A string containing the project name
	 */
	public String getMpName(UUID mpId) throws Exception;

	/**
	 * Get the type of a project
	 * 
	 * @param mpId
	 *            The unique integer ID of the project
	 * 
	 * @return A string containing the project type, for example: vensim -
	 *         "VENSIM" anylogic - "ANYLOGIC"
	 */
	public String getMpType(UUID mpId) throws Exception;

	/**
	 * Get the description of a project
	 * 
	 * @param mpId
	 *            The unique integer ID of the project
	 * @return A string containing the project description
	 */
	public String getMpDescription(UUID mpId) throws Exception;

	/**
	 * Get the creator of a project
	 * 
	 * @param mpId
	 *            The unique integer ID of the project
	 * @return A string containing the project creator
	 */
	public String getMpCreator(UUID mpId) throws Exception;

	/**
	 * Get the creation date of a project
	 * 
	 * @param mpId
	 *            The unique integer ID of the project
	 * @return The project creation date
	 */
	public Date getMpCreationDate(UUID mpId) throws Exception;

	/**
	 * Get the time of creation of a project
	 * 
	 * @param mpId
	 * @return The project creation time
	 */
	public Date getMpCreationTime(UUID mpId) throws Exception;

	/**
	 * Get the list of integer IDs of all versions contained in a project
	 * 
	 * @param mpId
	 *            The unique integer ID of the project
	 * @return An ArrayList<Integers> containing all version ids
	 */
	public ArrayList<UUID> getMpModelVersionIds(UUID mpId) throws Exception;

	/**
	 * Get the list of integer IDs and names of all versions contained in a
	 * project
	 * 
	 * @param mpId
	 *            The unique integer ID of the project
	 * @return A HashMap<Integer, String> containing all version ids and names
	 */
	public HashMap<UUID, String> getMpModelVersions(UUID mpId) throws Exception;

	// /**
	// * Returns the id of the most recently added model version
	// *
	// * @param mpId
	// * The unique integer ID of the project
	// * @return The integer id of the model version
	// */
	// public int getMpMostRecentModelVersionId(int mpId) throws Exception;

	/**
	 * Sets the name of a model project in the storage layer
	 * 
	 * @param mpId
	 *            The unique integer ID of the project
	 * @param name
	 *            The new name
	 * @return TODO
	 * @throws Exception
	 */
	public boolean setMpName(UUID mpId, String name) throws Exception;

	/**
	 * Sets the description of a project in the storage layer
	 * 
	 * @param mpId
	 *            The unique integer ID of the project
	 * @param description
	 *            The new description
	 * @return TODO
	 * @throws Exception
	 */
	public boolean setMpDescription(UUID mpId, String description)
			throws Exception;

	/**
	 * Sets the type of a project in the storage layer
	 * 
	 * @param mpId
	 *            The unique integer ID of the project
	 * @param mpType
	 *            The new type.
	 * @return TODO
	 * @throws Exception
	 */
	public boolean setMpType(UUID mpId, String mpType) throws Exception;

	/**
	 * Sets the mp unqiue string represented version
	 * 
	 * @param mpId
	 *            the model project database id
	 * @param version
	 *            a unique uuid id representation
	 * @return TODO
	 * 
	 */
	public boolean setMpVersion(UUID mpId, UUID version) throws Exception;

	/**
	 * Removes an entire model project from storage (should remove all
	 * associated artifacts - such as versions, collections, scenarios, etc.
	 * 
	 * @param mpId
	 *            The unique integer ID of the project
	 */
	public boolean deleteModelProject(UUID mpId) throws Exception;

	/* ==== Methods to Satisfy requests from ModelVersion ==== */

	/**
	 * Add a model version to storage
	 * 
	 * @param vName
	 *            The version name
	 * @param vCreator
	 *            The creator
	 * @param vDescr
	 *            A textual description of the version
	 * @param mpIdentity
	 *            The integer id of the parent project
	 * @param visbility
	 *            Currently a boolean number (1 for visible)
	 * @return The unique integer ID of the version
	 * @throws Exception
	 */
	public UUID addModelVersion(String vName, String vCreator, String vType,
			String vDescr, UUID mpIdentity, int visbility) throws Exception;

	/**
	 * Returns the XML representation of this version (non-recursive) as String
	 * 
	 * @param mvid
	 *            The unique integer ID of the version
	 * @return A string containing the XML representation of this version
	 */
	public String getModelVersionAsXML(UUID mvid) throws Exception;

	/**
	 * Returns the name of a version
	 * 
	 * @param mvId
	 *            The unique integer ID of the version
	 * @return The name of the version
	 */
	public String getMvName(UUID mvId) throws Exception;

	/**
	 * returns the latest version of the model version
	 * 
	 * @param mvId
	 *            the model version database id.
	 * @return the unique uuid representation of version
	 * 
	 */
	public UUID getMvVersion(UUID mvId) throws Exception;

	/**
	 * returns the time the model version last updated.
	 * 
	 * @param mvId
	 *            the model version database id.
	 * @return the unique uuid representation of version
	 * 
	 */
	public Date getMvUpdateTime(UUID mvId) throws Exception;

	/**
	 * Returns the type of a version, which is the type of model project.
	 * 
	 * @param mvId
	 *            The unique integer ID of the version
	 * @return The type of the version
	 */
	public String getMvType(UUID mvId) throws Exception;

	/**
	 * Returns the descriptions of a version
	 * 
	 * @param mvId
	 *            The unique integer ID of the version
	 * @return The description of this version
	 */
	public String getMvDescription(UUID mvId) throws Exception;

	/**
	 * Returns the creator of the version
	 * 
	 * @param mvId
	 *            The unique integer ID of the version
	 * @return The creator of this version
	 */
	public String getMvCreator(UUID mvId) throws Exception;

	/**
	 * Returns the creation date of this version
	 * 
	 * @param mvId
	 *            The unique integer ID of the version
	 * @return The creation date of this version
	 */
	public Date getMvCreationDate(UUID mvId) throws Exception;

	/**
	 * Returns the creation time of this version
	 * 
	 * @param mvId
	 *            The unique integer ID of the version
	 * @return The creation time of this version
	 */
	public Date getMvCreationTime(UUID mvId) throws Exception;

	/**
	 * Returns the unique integer Id of the project containing this version
	 * 
	 * @param mvId
	 *            The unique integer ID of the version
	 * @return The unique integer ID of the project containing this version
	 */
	public UUID getMvParentProjectId(UUID mvId) throws Exception;

	/**
	 * Returns the unique integer fileID of the source file from which this
	 * version was created
	 * 
	 * @param mvId
	 *            The unique integer ID of the version
	 * @return The unique file ID of this source file for this version
	 */
	public UUID getMvSourceFileId(UUID mvId) throws Exception;

	/**
	 * returns the name of the model version source file
	 * 
	 * @param mvId
	 *            the unique id of the model version
	 * @return the name of the source file
	 */
	public String getMvSourceFileName(UUID mvId) throws Exception;

	/**
	 * Returns the int id of the original scenario that was created when the
	 * version was first imported/created from a source file.
	 * 
	 * @param mvId
	 *            The unique integer ID of the version
	 * @return The unique integer ID of the original scenario
	 */
	public UUID getMvOriginalScenarioId(UUID mvId) throws Exception;

	/**
	 * Returns the int id of the baseline scenario for this version
	 * 
	 * @param mvId
	 *            The unique integer ID of the version
	 * @return The unique integer ID of the baseline scenario
	 */
	public UUID getMvBaselineScenarioId(UUID mvId) throws Exception;

	/**
	 * Returns the integer id of the most recently created scenario
	 * 
	 * @param mvId
	 *            The unique integer ID of the version
	 * @return The unique integer ID of the most recent scenario
	 */
	// public int getMvMostRecentScenarioId(int mvId) throws Exception;

	/**
	 * Returns an array of integer ids of all scenario collections for this
	 * version
	 * 
	 * @param mvId
	 *            The unique integer ID of the version
	 * @return An ArrayList<Integer> of scenario collection ids
	 */
	public ArrayList<UUID> getMvScenarioCollectionIds(UUID mvId)
			throws Exception;

	/**
	 * Returns a HashMap of integer ids and names of all scenario collections
	 * for this version
	 * 
	 * @param mvId
	 *            The unique integer ID of the version
	 * @return A HashMap<Integer, String> of scenario collection ids and names
	 */
	public HashMap<UUID, String> getMvParameterSetCollections(UUID mvId)
			throws Exception;

	/**
	 * Returns the integer id of the most recently created scenario collection
	 * for this version
	 * 
	 * @param mvId
	 *            The unique integer ID of the version
	 * @return The unique integer ID of the scenario collection
	 */
	// public int getMvMostRecentScenarioCollectionId(int mvId) throws
	// Exception;

	/**
	 * 
	 * set the UUID identity of current model version
	 * 
	 * @param mvId
	 *            the model version database id
	 * @param idenity
	 *            the uuid representation of version
	 * @return TODO
	 */
	public boolean setMvVersion(UUID mvId, UUID version) throws Exception;

	/**
	 * Sets the name of this version in the storage layer
	 * 
	 * @param mvId
	 *            The unique integer ID of the version
	 * @param name
	 *            The new name
	 * @return TODO
	 * @throws Exception
	 */
	public boolean setMvName(UUID mvId, String name) throws Exception;

	/**
	 * Sets the name of this version in the storage layer
	 * 
	 * @param mvId
	 *            The unique integer ID of the version
	 * @param type
	 *            The new type
	 * @return true if success, false otherwise
	 * 
	 */
	public boolean setMvType(UUID mvId, String type) throws Exception;

	/**
	 * Sets the Creator of the model version in the storage layer.
	 * 
	 * @param mvId
	 *            the unique ID of the version represented in UUID
	 * @param Creator
	 *            the new creator
	 * @return true if success, false otherwise
	 * 
	 */
	public boolean setMvCreator(UUID mvId, String creator) throws Exception;

	/**
	 * Sets the description of this version in the storage layer
	 * 
	 * @param mvId
	 *            The unique integer ID of the version
	 * @param description
	 *            The new description
	 * @return TODO
	 * @throws Exception
	 */
	public boolean setMvDescription(UUID mvId, String description)
			throws Exception;

	/**
	 * Sets the source file id for this version (the integer id of the file from
	 * which this version was created)
	 * 
	 * @param mvId
	 *            The unique integer ID of the version
	 * @param fID
	 *            The unique integer ID of the source file
	 * @return TODO
	 */
	public boolean setMvSourceFileId(UUID mvId, UUID fID) throws Exception;

	/**
	 * Sets the baseline scenario for this version
	 * 
	 * @param mvId
	 *            The unique integer ID of the version
	 * @param sId
	 *            The unique integer ID of the new baseline scenario
	 * @return TODO
	 */
	public boolean setMvBaselineScenario(UUID mvId, UUID sId) throws Exception;

	/**
	 * Sets the original scenario for this version (the scenario that was
	 * created from the parameters and values contained in the source file).
	 * 
	 * @param mvId
	 *            The unique integer ID of the version
	 * @param sId
	 *            The unique integer ID of the original
	 * @return TODO
	 */
	public boolean setMvOriginalScenario(UUID mvId, UUID sId) throws Exception;

	/**
	 * Removes a model version from storage, recursively (should remove all
	 * associated collections, scenarios, parameters, etc.)
	 * 
	 * @param mvId
	 *            The unique integer ID of the version to be deleted
	 * @return TODO
	 */
	public boolean deleteVersion(UUID mvId) throws Exception;

	/* ==== Methods to Satisfy requests from ScenarioCollection ==== */
	/**
	 * Adds a scenario collection to the storage layer
	 * 
	 * @param scName
	 *            The name of the collection
	 * @param scCreator
	 *            The creator of the collection
	 * @param scDescr
	 *            A textual description of the collection
	 * @param mvId
	 *            The unique integer ID of the version this collection belongs
	 *            to
	 * @return The unique integer ID of the scenario collection
	 * @throws Exception
	 */
	public UUID addScenarioCollection(String scName, String scCreator,
			String scDescr, UUID mvId) throws Exception;

	/**
	 * Returns the XML representation of this scenario collection
	 * (non-recursive) as string
	 * 
	 * @param scId
	 *            The unique integer ID of the scenario collection
	 * @return A string containing the XML represenation of this scenario
	 *         collection
	 */
	public String getScenarioCollectionAsXML(UUID scId) throws Exception;

	/**
	 * Returns the name of this scenario collection
	 * 
	 * @param scId
	 *            The unique integer ID of the scenario collection
	 * @return The name
	 */
	public String getScenarioCollectionName(UUID scId) throws Exception;

	/**
	 * Returns the description of this collection
	 * 
	 * @param scId
	 *            The unique integer ID of the scenario collection
	 * @return The description of this collection
	 */
	public String getScenarioCollectionDescription(UUID scId) throws Exception;

	/**
	 * Returns the name of the creator of this collection
	 * 
	 * @param scId
	 *            The unique integer ID of the scenario collection
	 * @return The creator
	 */
	public String getScenarioCollectionCreator(UUID scId) throws Exception;

	/**
	 * Returns the creation date of this scenario collection
	 * 
	 * @param scId
	 *            The unique integer ID of the scenario collection
	 * @return The creation date
	 */
	public Date getScenarioCollectionCreationDate(UUID scId) throws Exception;

	/**
	 * Returns the creation time of this scenario collection
	 * 
	 * @param scId
	 *            The unique integer ID of the scenario collection
	 * @return The creation time
	 */
	public Date getScenarioCollectionCreationTime(UUID scId) throws Exception;

	/**
	 * Returns the unique integer id of the version containing this scenario
	 * collection.
	 * 
	 * @param scId
	 *            The unique integer ID of the scenario collection
	 * @return The unique integer ID of the parent version
	 */
	public UUID getScenarioCollectionParentVersionId(UUID scId)
			throws Exception;

	/**
	 * Returns an ArrayList<Integer> of the integer ids of all scenarios
	 * contained in this scenario collection
	 * 
	 * @param scId
	 *            The unique integer ID of the scenario collection
	 * @return An ArrayList<Integer> of all scenario ids contained in this
	 *         collection
	 */
	public ArrayList<UUID> getScenarioCollectionScenarioIds(UUID scId)
			throws Exception;

	/**
	 * Returns an ArrayList<Integer> of the integer ids of all files associated
	 * with this model project.
	 * 
	 * @param mpId
	 *            The unique integer ID of the ModelProject
	 * @return An ArrayList<Integer> of all associated file ids
	 */
	public ArrayList<UUID> getModelProjectAssociatedFileIds(UUID mpId)
			throws Exception;

	/**
	 * Returns an ArrayList<Integer> of the integer ids of all files associated
	 * with this model version.
	 * 
	 * @param mvId
	 *            The unique integer ID of the model version
	 * @return An ArrayList<Integer> of all associated file ids
	 */
	public ArrayList<UUID> getModelVersionAssociatedFileIds(UUID mvId)
			throws Exception;

	/**
	 * Returns an ArrayList<Integer> of the integer ids of all files associated
	 * with this scenario.
	 * 
	 * @param sId
	 *            The unique integer ID of the scenario
	 * @return An ArrayList<Integer> of all associated file ids
	 */
	public ArrayList<UUID> getScenarioAssociatedFileIds(UUID sId)
			throws Exception;

	/**
	 * Returns an ArrayList<Integer> of the unique ids of all files associated
	 * with this scenario collection.
	 * 
	 * @param scId
	 *            The unique integer ID of the scenario collection
	 * @return An ArrayList<Integer> of all associated file ids
	 */
	public ArrayList<UUID> getScenarioCollectionAssociatedFileIds(UUID scId)
			throws Exception;

	/**
	 * Returns an ArrayList<String> of the file names of all files associated
	 * with this scenario collection.
	 * 
	 * @param scId
	 *            The unique id of the scenario collection
	 * @return An ArrayList<String> of all associated file ids
	 */
	public ArrayList<String> getScenarioCollectionAssociatedFileNames(UUID scId)
			throws Exception;

	/**
	 * Returns an HashMap<Integer, String> of the integer ids and string names
	 * of all scenarios contained in this scenario collection
	 * 
	 * @param scId
	 *            The unique integer ID of the scenario collection
	 * @return AHashMap<Integer, String> of the integer ids and string names of
	 *         scenarios contained in this collection
	 */
	public HashMap<UUID, String> getScenarioCollectionScenarioIdsAndNames(
			UUID scId) throws Exception;

	/**
	 * Returns the integer id of the most recently added scenario within this
	 * collection
	 * 
	 * @param scId
	 *            The unique integer ID of the scenario collection
	 * @return The unique integer ID of the most recent scenario
	 */
	public UUID getScenarioCollectionMostRecentScenarioId(UUID scId)
			throws Exception;

	/**
	 * returns the unique UUID representation of the scenario collection
	 * identity
	 * 
	 * @param scId
	 *            the scenario collection database id
	 * @return the unique UUID object
	 * 
	 */
	public UUID getScenarioCollectionIdentity(UUID scId) throws Exception;

	/**
	 * returns the unique UUID representation of the scenario collection version
	 * 
	 * @param scId
	 *            the scenario collection database id
	 * @return
	 * @throws Exception
	 */
	public UUID getScenarioCollectionVersion(UUID scId) throws Exception;

	/**
	 * returns the time when the scenario collection last updated.
	 * 
	 * @param scId
	 *            the scenario collection database id
	 * @return the Date object containing a precise time
	 * 
	 */
	public Date getScenarioCollectionUpdateTime(UUID scId) throws Exception;

	/**
	 * Sets the name of this scenario collection in the storage layer
	 * 
	 * @param scId
	 *            The unique integer ID of the scenario collection
	 * @param name
	 *            The new name
	 * @return TODO
	 * @throws Exception
	 */
	public boolean setScenarioCollectionName(UUID scId, String name)
			throws Exception;

	/**
	 * Sets the description of this scenario collection in the storage layer
	 * 
	 * @param scId
	 *            The unique integer ID of the scenario collection
	 * @param description
	 *            The new description
	 * @return TODO
	 * @throws Exception
	 */
	public boolean setScenarioCollectionDescr(UUID scId, String description)
			throws Exception;

	/**
	 * 
	 * @param scId
	 *            the unique scenario collection id
	 * @param updatedVersion
	 * @return true if the modification was successful, false otherwise
	 * 
	 */
	public boolean setScenarioCollectionVersion(UUID scId, UUID updatedVersion)
			throws Exception;

	/**
	 * Sets the creator of the scenario collection
	 * 
	 * @param scId
	 *            the unique scenario collection id
	 * @param updateCreator
	 * @return true if the modification was successful, false otherwise
	 */
	public boolean setScenarioCollectionCreator(UUID scId, String updateCreator)
			throws Exception;

	/**
	 * Removes a scenario collection (recursively) from storage - i.e. removes
	 * all asscociated scenarios, parameter sets, etc.
	 * 
	 * @param scId
	 * @return TODO
	 */
	public boolean deleteScenarioCollection(UUID scId) throws Exception;

	/**
	 * Removes all associated files of current scenario collection Buggy, don't
	 * use for now.
	 * 
	 * @param scId
	 * @return
	 * @throws Exception
	 */
	public boolean deleteAllScenarioCollectionAssociatedFiles(UUID scId)
			throws Exception;

	/* ==== Methods to Satisfy requests from Scenario ==== */

	/**
	 * Adds a scenario to storage. Requires that a parameter set has already
	 * been created.
	 * 
	 * @param sName
	 *            The name of the scenario
	 * @param sCreator
	 *            The creator of the scenario
	 * @param sType
	 *            The type of the scenario
	 * @param sDescr
	 *            A textual description of the scenario
	 * @param mvId
	 *            The integer id of the version this scenario belongs to
	 * @param scId
	 *            The integer id of the scenario collection this scenario
	 *            belongs to
	 * @param psId
	 *            The integer id of the parameter set that belongs to this
	 *            scenario
	 * @return The unique integer ID of the scenario
	 * @throws Exception
	 */
	public UUID addScenario(String sName, String sCreator, String sType,
			String sDescr, UUID mvId, UUID scId, int psId) throws Exception;

	/**
	 * Returns a string containing the XML representation of this scenario
	 * (non-recursive)
	 * 
	 * @param sId
	 *            The unique integer ID of the scenario
	 * @return String containing the XML representation of this scenario
	 */
	public String getScenarioAsXML(UUID sId) throws Exception;

	/**
	 * returns UUID representation of the uniquescenario identity
	 * 
	 * @param sId
	 *            the scenario database id
	 * @return a uuid object
	 * 
	 */
	public UUID getScenarioIdentity(UUID sId) throws Exception;

	/**
	 * returns UUID representation of the uniquescenario version
	 * 
	 * @param sId
	 *            the scenario database id
	 * @return a uuid object
	 * 
	 */
	public UUID getScenarioVersion(UUID sId) throws Exception;

	/**
	 * returns the time when the scenario last updated
	 * 
	 * @param sId
	 *            the scenario database id
	 * @return a Date object containing the precise time
	 * 
	 */
	public Date getScenarioUpdateTime(UUID sId) throws Exception;

	/**
	 * Returns the name of this scenario
	 * 
	 * @param sId
	 *            The unique integer ID of the scenario
	 * @return The name of this scenario
	 */
	public String getScenarioName(UUID sId) throws Exception;

	/**
	 * Check whether the selected scenario is a baseline scenario
	 * 
	 * @param sId
	 *            the unique id of the scenario
	 * @return true if the sceanrio is a baseline scenario, false otherwise
	 * 
	 */
	public boolean isBaselineScenario(UUID sId) throws Exception;

	/**
	 * Returns the type of this scenario
	 * 
	 * @param sId
	 *            The unique integer ID of the scenario
	 * @return The type of this scenario, for example; vensim -- "VENSIM"
	 *         anylogic -- "ANYLOGIC"
	 */
	public String getScenarioType(UUID sId) throws Exception;

	/**
	 * Returns the description of this scenario
	 * 
	 * @param sId
	 *            The unique integer ID of the scenario
	 * @return The description of this scenario
	 */
	public String getScenarioDescription(UUID sId) throws Exception;

	/**
	 * Returns the name of the creator of this scenario
	 * 
	 * @param sId
	 *            The unique integer ID of the scenario
	 * @return The creator of this scenario
	 */
	public String getScenarioCreator(UUID sId) throws Exception;

	/**
	 * Returns the date of when this scenario was created
	 * 
	 * @param sId
	 *            The unique integer ID of the scenario
	 * @return The creation date
	 */
	public Date getScenarioCreationDate(UUID sId) throws Exception;

	/**
	 * Returns the time of when this scenario was created
	 * 
	 * @param sId
	 *            The unique integer ID of the scenario
	 * @return The creation date
	 */
	public Date getScenarioCreationTime(UUID sId) throws Exception;

	/**
	 * Returns the integer id of the version containing this scenario
	 * 
	 * @param sId
	 *            The unique integer ID of the scenario
	 * @return The integer id of the parent version
	 */
	public UUID getScenarioParentVersionId(UUID sId) throws Exception;

	/**
	 * Returns the type specified by the parent model version
	 * 
	 * @param sId
	 * @return
	 * @throws NullPointerException
	 * @throws SQLException
	 */
	public String getScenarioParentVersionSimulationType(UUID sId)
			throws Exception;

	/**
	 * Returns the integer id of the scenario collection containing this
	 * scenario
	 * 
	 * @param sId
	 *            The unique integer ID of the scenario
	 * @return The id of the parent scenario collection
	 */
	public UUID getScenarioParentScenarioCollectionId(UUID sId)
			throws Exception;

	/**
	 * Returns the integer id of the parameter set for this scenario
	 * 
	 * @param sId
	 *            The unique integer ID of the scenario
	 * @return The integer id of the parameter set
	 */
	public int getScenarioParameterSetId(UUID sId) throws Exception;

	/**
	 * Returns the date for which a simulation of this scenario was last started
	 * 
	 * @param sId
	 *            The unique integer ID of the scenario
	 * @return The simulation run start time of this scenario
	 */
	public Date getScenarioRunStartTime(UUID sId) throws Exception;

	/**
	 * Returns the date for which a simulation of this scenario was last ended
	 * 
	 * @param sId
	 *            The unique integer ID of the scenario
	 * @return The simulation run end time of this scenario
	 */
	public Date getScenarioRunEndTime(UUID sId) throws Exception;

	/**
	 * Returns the name of the user who last ran this scenario
	 * 
	 * @param sId
	 *            The unique integer ID of the scenario
	 * @return The user name
	 */
	public String getScenarioRunUser(UUID sId) throws Exception;

	/**
	 * Returns an array of all integer ids of input files for this scenario
	 * 
	 * @param sId
	 *            The unique integer ID of the scenario
	 * @return ArrayList<UUID> of input file ids
	 */
	public ArrayList<UUID> getScenarioInputFileIds(UUID sId) throws Exception;

	/**
	 * Returns the id for the first of the input files from this scenario
	 * 
	 * @param sId
	 *            The unique id of the scenario
	 * @return fId
	 * @throws Exception
	 */
	public UUID getScenarioFirstInputFileId(UUID sId) throws Exception;

	/**
	 * Returns the name for the first of the input files from this scenario
	 * 
	 * @param sId
	 *            The unique id of the scenario
	 * @return input file name
	 * @throws NullPointerException
	 */
	public String getScenarioFirstInputFileName(UUID sId) throws Exception;

	/**
	 * Returns an array of all integer ids of trajectory files for this scenario
	 * 
	 * @param sId
	 *            The unique integer ID of the scenario
	 * @return ArrayList<Integer> of trajectory file ids
	 */
	public ArrayList<UUID> getScenarioTrajectoryFileIds(UUID sId)
			throws Exception;

	/**
	 * Returns an array of all integer ids of analysis files for this scenario
	 * 
	 * @param sId
	 *            The unique integer ID of the scenario
	 * @return ArrayList<Integer> of analysis file ids
	 */
	public ArrayList<UUID> getScenarioAnalysisFileIds(UUID sId)
			throws Exception;

	/**
	 * Sets the name of a scenario in the storage layer
	 * 
	 * @param sId
	 *            The unique integer ID of the scenario
	 * @param name
	 *            The new name
	 * @return TODO
	 * @throws Exception
	 */
	public boolean setScenarioName(UUID sId, String name) throws Exception;

	/**
	 * Sets the unique version of a scenario in the connected database
	 * 
	 * @param sId
	 *            the scenario database id
	 * @param version
	 *            the uuid representation of a scenario identity
	 * @return TODO
	 * 
	 */
	public boolean setScenarioVersion(UUID sId, UUID version) throws Exception;

	/**
	 * Sets the type of a scenario in the storage layer
	 * 
	 * @param sId
	 *            The unique integer ID of the scenario
	 * @param sType
	 *            The new type
	 * @return TODO
	 * @throws Exception
	 */
	public boolean setScenarioType(UUID sId, String sType) throws Exception;

	/**
	 * Sets the creator of a scenario in the storage layer
	 * 
	 * @param sId
	 *            The unique identity of the scenario
	 * @param sCreator
	 *            The new creator
	 * @return True of the routine succeed, false otherwise
	 * 
	 */
	public boolean setScenarioCreator(UUID sId, String sCreator)
			throws Exception;

	/**
	 * Sets the description of a scenario in the storage layer
	 * 
	 * @param sId
	 *            The unique integer ID of the scenario
	 * @param description
	 *            The new description
	 * @return TODO
	 * @throws Exception
	 */
	public boolean setScenarioDescription(UUID sId, String description)
			throws Exception;

	/**
	 * Sets the parent scenario collection id for this scenario (necessary since
	 * scenarios can be moved between scenario collections).
	 * 
	 * @param sId
	 *            The unique integer ID of the scenario
	 * @param scId
	 *            The unique integer ID of the scenario collection
	 * @return TODO
	 */
	public boolean setScenarioScenarioCollectionId(UUID sId, UUID scId)
			throws Exception;

	/**
	 * Set the name of the user who ran a scenario
	 * 
	 * @param sId
	 *            The unique integer ID of the scenario
	 * @param user
	 *            The name of the user
	 * @return TODO
	 * @throws Exception
	 */
	public boolean setScenarioRunUser(UUID sId, String user) throws Exception;

	/**
	 * Sets the run start time for a simulation run of this scenario (simply
	 * sets it to CURRENT_TIME)
	 * 
	 * @param sId
	 *            The unique integer ID of the scenario
	 * @return TODO
	 */
	public boolean setScenarioRunStartTime(UUID sId) throws Exception;

	/**
	 * Sets the run end time for a simulation run of this scenario (simply sets
	 * it to CURRENT_TIME)
	 * 
	 * @param sId
	 *            The unique integer ID of the scenario
	 * @return TODO
	 */
	public boolean setScenarioRunEndTime(UUID sId) throws Exception;

	/**
	 * Removes a scenario from storage (recursively) - i.e. removes the
	 * associated parameterset, inputFiles, etc.
	 * 
	 * @param sId
	 *            The unique integer ID of the scenario
	 * @return TODO
	 */
	public boolean deleteScenario(UUID sId) throws Exception;

	/*
	 * ==== Methods to Satisfy requests from Scenario regarding ParameterSets
	 * ====
	 */

	/**
	 * Add a parameter set to storage
	 * 
	 * @param description
	 *            The description of the parameter set
	 * @return The unique integer ID of the parameter set
	 * @throws Exception
	 */
	public int addParameterSet(String description) throws Exception;

	/**
	 * Returns the contents (parameters and values) of a parameter set as
	 * w3c.Document (DOM) This is needed for overriding parameter values during
	 * simulation runs using aspects.
	 * 
	 * @param psId
	 *            The unique integer ID of the parameter set
	 * @return A DOM of the parameter set contents. Return value could be null.
	 */
	public Document getParameterSetParametersAsDom(int psId) throws Exception;

	/**
	 * Returns the description of a parameter set
	 * 
	 * @param psId
	 *            The unique integer ID of the parameter set
	 * @return The description
	 */
	public String getParameterSetDescription(int psId) throws Exception;

	/**
	 * Returns an ArrayList<Integer> of the integer ids of all parameters
	 * contained in this parameter set
	 * 
	 * @param psId
	 *            The unique integer ID of the parameter set
	 * @return An ArrayList<Integer> of the integer ids of all parameters
	 */
	public ArrayList<Integer> getParameterSetParameterIds(int psId)
			throws Exception;

	/**
	 * Returns the value of a parameter within a scenario. Parameters are the
	 * same across multiple scenarios, but their values and descriptions differ
	 * - hence this method.
	 * 
	 * @param sId
	 *            The integer id of the scenario (contains a unique parameter
	 *            set)
	 * @param pId
	 *            The integer id of the parameter
	 * @return The value of the parameter for this scenario
	 */
	public String getScenarioParameterValue(int sId, int pId) throws Exception;

	/**
	 * Returns the comment of a parameter within a scenario. Parameters are the
	 * same across multiple scenarios, but their values and descriptions differ
	 * - hence this method.
	 * 
	 * @param sId
	 *            The integer id of the scenario (contains a unique parameter
	 *            set)
	 * @param pId
	 *            The integer id of the parameter
	 * @return The comment of a parameter for this scenario
	 */
	public String getScenarioParameterComment(int sId, int pId)
			throws Exception;

	/**
	 * Sets the description of this parameter set in the storage layer
	 * 
	 * @param psId
	 *            The unique integer ID of the parameter set
	 * @param description
	 *            The new description
	 * @throws Exception
	 */
	public void setParameterSetDescription(int psId, String description)
			throws Exception;

	/**
	 * Set the comment for a parameter in a scenario (i.e. the reasoning for the
	 * choice of parameter value in this scenario)
	 * 
	 * @param sId
	 *            The unique integer ID of the scenario
	 * @param pId
	 *            The unique integer ID of the parameter
	 * @param comment
	 *            The comment for this parameter in this scenario
	 * @throws Exception
	 */
	public void setScenarioParameterComment(int sId, int pId, String comment)
			throws Exception;

	/**
	 * Removes a parameter set from storage
	 * 
	 * @param psId
	 *            The unique integer ID of the parameter set
	 */
	public void deleteParameterSet(int psId) throws Exception;

	/* ==== Methods to Satisfy requests from Parameter ==== */

	/**
	 * Adds a parameter to storage. Requires that a parameter set has already
	 * been created
	 * 
	 * @param pName
	 *            The name of the parameter (from source file)
	 * @param pUnits
	 *            The units of a parameter (user defined)
	 * @param pType
	 *            The type of the parameter (from source file)
	 * @param pClass
	 *            The class/parent containing this parameter (from source file)
	 * @param pDescr
	 *            The description of the parameter (user defined)
	 * @param psId
	 *            The integer id of the parameter set this parameter belongs to
	 * @param pValue
	 *            The value of the parameter in this parameter set
	 * @param pValComment
	 *            Comment on the value of the parameter in this parameter set
	 * @return The unique integer ID of the parameter
	 * @throws Exception
	 */
	public int addParameter(String pName, String pUnits, String pType,
			String pClass, String pDescr, int psId, String pValue,
			String pValComment) throws Exception;

	/**
	 * Returns a string containing the XML representation of this parameter
	 * 
	 * @param pId
	 *            The unique integer ID of the parameter
	 * @return String containing the XML representation of this parameter
	 */
	public String getParameterAsXML(int pId) throws Exception;

	/**
	 * Returns the name of a parameter
	 * 
	 * @param pId
	 *            The unique integer ID of the parameter
	 * @return The parameter name
	 */
	public String getParameterName(int pId) throws Exception;

	/**
	 * Returns the type of a parameter
	 * 
	 * @param pId
	 *            The unique integer ID of the parameter
	 * @return The parameter type
	 */
	public String getParameterType(int pId) throws Exception;

	/**
	 * Returns the units of a parameter
	 * 
	 * @param pId
	 *            The unique integer ID of the parameter
	 * @return The parameter units
	 */
	public String getParameterUnits(int pId) throws Exception;

	/**
	 * Returns the associated/parent class of a parameter
	 * 
	 * @param pId
	 *            The unique integer ID of the parameter
	 * @return The parameter's parent/associated class
	 */
	public String getParameterAssociatedClass(int pId) throws Exception;

	/**
	 * Returns the description of a parameter
	 * 
	 * @param pId
	 *            The unique integer ID of the parameter
	 * @return The parameter description
	 */
	public String getParameterDescription(int pId) throws Exception;

	/**
	 * returns the parent parameter set id of a parameter
	 * 
	 * @param pId
	 *            the parameter id
	 * @return psId the parameter set id
	 * 
	 */
	public int getParameterParentParameterSetId(int pId) throws Exception;

	/**
	 * Sets the parent/associated class of a parameter in the storage layer
	 * 
	 * @param pId
	 *            The unique integer ID of the parameter
	 * @param associatedClass
	 *            The new parent/associated class
	 * @throws Exception
	 */
	public void setParameterAssociatedClass(int pId, String associatedClass)
			throws Exception;

	/**
	 * Sets the units of a parameter in the storage layer
	 * 
	 * @param pId
	 *            The unique integer ID of the parameter
	 * @param units
	 *            The new parameter units
	 * @throws Exception
	 */
	public void setParameterUnits(int pId, String units) throws Exception;

	/**
	 * Sets the description of a parameter in the storage layer
	 * 
	 * @param pId
	 *            The unique integer ID of the parameter
	 * @param description
	 *            The new parameter description
	 * @return TODO
	 * @throws Exception
	 */
	public boolean setParameterDescription(int pId, String description)
			throws Exception;

	/**
	 * Add an existing parameter to a different parameter set. Requires that a
	 * value and reasoning for the value assignment are given.
	 * 
	 * @param pId
	 *            The unique integer ID of the parameter
	 * @param psId
	 *            The unique integer ID of the parameter set
	 * @param value
	 *            The parameter value in this parameter set
	 * @param comment
	 *            The parameter value comment for the parameter in this
	 *            parameter set
	 * @throws Exception
	 */
	public void addParameterToParameterSet(int pId, int psId, String value,
			String comment) throws Exception;

	/**
	 * Removes a parameter from the storage layer
	 * 
	 * @param pId
	 *            The unique integer ID of the parameter
	 * @return TODO
	 */
	public boolean deleteParameter(int pId) throws Exception;

	/* ==== Methods to Satisfy requests from File ==== */

	/**
	 * Adds a file to the storage layer.
	 * 
	 * @param fName
	 *            The name of the file
	 * @param fDescr
	 *            A file description
	 * @param fileSourceLocation
	 *            The location of the file (where it should be retrieved from to
	 *            store)
	 * @return The unique integer ID of the file
	 * @throws IOException
	 * @throws Exception
	 */
	public UUID addFile(String fName, String fDescr, String fileSourceLocation)
			throws IOException, Exception;

	/**
	 * Returns the name of a file
	 * 
	 * @param fId
	 *            The unique integer ID of the file
	 * @return The file name
	 */
	public String getFName(UUID fId) throws Exception;

	/**
	 * Returns the description of a file
	 * 
	 * @param fId
	 *            The unique integer ID of the file
	 * @return The file description
	 */
	public String getFDescription(UUID fId) throws Exception;

	/**
	 * Saves a file to a specific destination
	 * 
	 * @param fId
	 *            The unique integer ID of the file
	 * @param destination
	 *            The location of where the file should be recreated at
	 */
	public void getFFileToLocalStorage(UUID fId, File destination)
			throws Exception;

	/**
	 * Sets the name of a file in the storage layer
	 * 
	 * @param fId
	 *            The UUID id of the file
	 * @param name
	 *            the new file name
	 * @return True if the operation succeeds, fail otherwise
	 */
	public boolean setFName(UUID fId, String name) throws Exception;

	/**
	 * Sets the description of a file in the storage layer
	 * 
	 * @param fId
	 *            The UUID id of the file
	 * @param name
	 *            the new file description
	 * @return True if the operation succeeds, fail otherwise
	 */
	public boolean setFDescription(UUID fId, String description)
			throws Exception;

	/**
	 * Associate a file with a scenario as input file
	 * 
	 * @param fId
	 *            The unique integer ID of the file
	 * @param sId
	 *            The unique integer ID of the scenario
	 * @return TODO
	 */
	public boolean addFFileToScenarioAsInputFile(UUID fId, UUID sId)
			throws Exception;

	/**
	 * Associate a file with a scenario as trajectory file
	 * 
	 * @param fId
	 *            The unique integer ID of the file
	 * @param sId
	 *            The unique integer ID of the scenario
	 * @return TODO
	 */
	public boolean addFFileToScenarioAsTrajectoryFile(UUID fId, UUID sId)
			throws Exception;

	/**
	 * Associate a file with a scenario as analysis file
	 * 
	 * @param fId
	 *            The unique integer ID of the file
	 * @param sId
	 *            The unique integer ID of the scenario
	 * @return TODO
	 */
	public boolean addFFileToScenarioAsAnalysisFile(UUID fId, UUID sId)
			throws Exception;

	/**
	 * Associate a file with a scenario collection
	 * 
	 * @param fId
	 *            The unique integer ID of the file
	 * @param scId
	 *            The unique integer ID of the scenario collection
	 * @return TODO
	 */
	public boolean addFileToScenarioCollection(UUID fId, UUID scId)
			throws Exception;

	/**
	 * Associate a file with a model project
	 * 
	 * @param fId
	 *            The unique integer ID of the file
	 * @param mpId
	 *            The unique integer ID of the model project
	 * @return TODO
	 */
	public boolean addFileToModelProject(UUID fId, UUID mpId) throws Exception;

	/**
	 * Associate a file with a scenario collection
	 * 
	 * @param fId
	 *            The unique integer ID of the file
	 * @param mvId
	 *            The unique integer ID of the model version
	 * @return TODO
	 */
	public boolean addFileToModelVersion(UUID fId, UUID mvId) throws Exception;

	/**
	 * Associate a file with a scenario
	 * 
	 * @param fId
	 *            The unique integer ID of the file
	 * @param sId
	 *            The unique integer ID of the scenario
	 * @return TODO
	 */
	public boolean addFileToScenario(UUID fId, UUID sId) throws Exception;

	/**
	 * Removes a file from the storage layer
	 * 
	 * @param fId
	 *            The unique integer ID of the file
	 * @return TODO
	 */
	public boolean deleteFile(UUID fId) throws Exception;

	/**
	 * duplicate a file within the storage
	 * 
	 * @param fId
	 *            The unique UUID of the file
	 * @return the duplicated file id
	 * @throws Exception
	 *             SQLException
	 */
	public UUID duplicateFile(UUID fId) throws Exception;

	/**
	 * Duplicate a scenario
	 * 
	 * @param sId
	 *            The unique integer ID of the scenario
	 * 
	 * @param scId
	 *            The unique integer ID of the destination scenario collection
	 * 
	 * @return The unique UUID of the duplicated scenario
	 */
	public UUID duplicateScenario(UUID sId, UUID scId) throws Exception;

	/**
	 * Duplicate a parameter set row in database
	 * 
	 * @param psId
	 *            parameter set integer id
	 * @return the new parameter set id
	 * @throws Exception
	 */
	public int duplicateParameterSetRow(int psId) throws Exception;


	/**
	 * Duplicate a scenario collection
	 * 
	 * @param scId
	 *            The unique integer ID of the scenario collection
	 * 
	 * @param mvId
	 *            The unique integer ID of the destination model version
	 * 
	 * @return The unique integer ID of the duplicated scenario collection
	 */
	public UUID duplicateScenarioCollection(UUID scId, UUID mvId)
			throws Exception;

	/**
	 * Duplicate a scenario with Stored Procedure
	 * 
	 * @param sId
	 *            The unique integer ID of the scenario
	 * 
	 * @param scId
	 *            The unique integer ID of the destination scenario collection
	 * 
	 * @return The unique integer ID of the duplicated scenario
	 */
	public int duplicateScenarioWithSP(int sId, int scId) throws Exception;

	/**
	 * Same as {@link #getAllUserIDs()} but uses a database procedure
	 * 
	 * @return A list of user IDs
	 * @throws Exception
	 *             SQLException
	 */
	public ArrayList<UUID> getAllUserIDsThroughProcedure() throws Exception;

	/**
	 * Duplicate all parameters between two different ParameterSets
	 * 
	 * @param psIdFrom
	 *            - the integer id of the parameter set to copy from
	 * @param psIdTo
	 *            - the integer id of the parameter set to copy to
	 * @throws Exception
	 */
	public void duplicateParametersBetweenParameterSets(int psIdFrom, int psIdTo)
			throws Exception;

	public void duplicateScenarioTrajectoryFile(UUID fromSId, UUID toSId)
			throws Exception;

	/**
	 * Duplicate all scenario input file
	 * 
	 * @param fromSId
	 * @param toSId
	 * @throws Exception
	 */
	public void duplicateScenarioInputFile(UUID fromSId, UUID toSId)
			throws Exception;

	/**
	 * Duplicate all scenario analysis file
	 * 
	 * @param fromSId
	 * @param toSId
	 * @throws Exception
	 */
	public void duplicateScenarioAnalysisFile(UUID fromSId, UUID toSId)
			throws Exception;

	public boolean setScenarioAsBaselineScenarioToParentVersion(UUID sId)
			throws Exception;

	public void duplicateScenarioAssociatedFile(UUID fromSId, UUID toSId)
			throws Exception;

	public String getScenarioUndecodedParameterSetInfoAsXML(UUID sId)
			throws Exception;

	public String getScenarioCollectionUndecodedInfoAsXML(UUID scId)
			throws Exception;

	public String getModelVersionUndecodedInfoAsXML(UUID mvId) throws Exception;

	public String getModelProjectUndecodedInfoAsXML(UUID mpId) throws Exception;

	public String getGroupUndecodedInfoAsXML(UUID gId) throws Exception;

	public String getUserUndecodedInfoAsXML(UUID uId) throws Exception;

	public DataSource getCurrentDS() throws Exception;

}
